package com.class06.ioc_02;


import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Component
//@Scope("prototype")
public class JavaBean {


//    定义生命的周期方法：必须是 public void 方法名任意 无参数


    @PostConstruct   // 相当于 <bean init-method="init"/>
    public void init() {
        System.out.println("初始化方法");
    }

    @PreDestroy   // 相当于 <bean destroy-method="destroy"/>
    public void destroy() {
        System.out.println("销毁方法");
    }


}
